package com.yoi.SendAndRecv;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.util.Map;

//Version3

/**
 * 接收第二个账户key为hello2的信息 Topic模式
 */
//@Component
@RabbitListener(bindings=@QueueBinding(value=@Queue(value="Second-queue",durable="ture"),
        exchange=@Exchange(name="Second-exchange",durable="true",type="topic"), key="hello2.*"),containerFactory = "SecondContainerFactory")
public class Receiver2 {

    @RabbitHandler
    public void process(@Payload String body, @Headers Map<String,Object> headers, Channel channel) {
        System.out.println("Receiver2 : " + body);
    }

}